package com.example.springweb.controller;


import com.example.springweb.pojo.User;
import com.example.springweb.service.UserService;
import com.example.springweb.utils.LoginReturnMessage;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin
public class UserController {
    @Autowired
    private UserService userService;




    @RequestMapping("/trylogin")
    public LoginReturnMessage TryLogin(String user, String password){
        return userService.TryLogin(new User(user,password));
    }

    @RequestMapping("/resgister")
    public String Resgister(String user,String password){
        return userService.Register(new User(user,password));
    }

    @GetMapping("/")
    public String test(){
        return "successful";
    }
}
